import VueRouter from "vue-router";

import lay from '@/view/lay'

// 首页
import index from '@/view/index/index'
import home from '@/view/index/home/home'
import bookshelf from '@/view/index/book/bookshelf'
import user from '@/view/index/user'


import userUpdate from '@/view/index/user/update'

// 普通音乐页面
import ordinary from '@/view/ordinary/ordinary'
import like from '@/view/ordinary/like/like'
import collection from '@/view/ordinary/collection/collection'
import playlist from '@/view/ordinary/playlist/playlist'
import search from '@/view/ordinary/search/search'
import songDetail from '@/view/ordinary/songDetail/songDetail'
import songSheet from '@/view/ordinary/songSheet/songSheet'
import createSongSheet from '@/view/ordinary/createSongSheet/index.vue'

// 普通小说页面
import clockBoots from '@/view/ordinary/clockBoots/clockBoots'
import bookRead from '@/view/ordinary/bookRead/bookRead'
import bookDetail from '@/view/ordinary/bookDetail/bookDetail'
import fictionClass from '@/view/ordinary/fictionClass/fictionClass'
import fictionList from '@/view/ordinary/fictionList/fictionList'



//影视相关页面
import video from '@/view/video/video'
import moviesPlay from '@/view/ordinary/moviesPlay/moviesPlay'
import moviesDetail from '@/view/ordinary/moviesDetail/moviesDetail'

// 授权
import login from '@/view/auth/login'
import downClient from '@/view/auth/downClient'
import findPassword from '@/view/auth/findPassword'

// APP
import setting from '@/view/ordinary/setting/setting'
import bookReadSetting from '@/view/ordinary/setting/bookReadSetting'

export const router = new VueRouter({
    routes:[
        {
            path : '*',
            redirect : '/home'
        },
        {
            path : '/lay',
            name : 'lay',
            component : lay,
            children : [
                // 首页
                {
                    path : '/index',
                    name : 'index',
                    component : index,
                    children : [
                        {
                            path : '/bookshelf',
                            name : 'bookshelf',
                            component : bookshelf,
                            meta : {
                                notAudio : true,
                                leavel : true,
                            }
                        },
                        {
                            path : '/home',
                            name : 'home',
                            component : home,
                            meta : {
                                leavel : true,
                            }
                        },
                        {
                            path : '/user',
                            name : 'user',
                            component : user,
                            meta : {
                                leavel : true,
                            }
                        }
                    ]
                },
                
                // 普通页面
                {
                    path : '/ordinary',
                    name : 'ordinary',
                    component : ordinary,
                    children : [
                        {
                            path : '/playlist',
                            name : 'playlist',
                            component : playlist
                        },
                        {
                            path : '/like',
                            name : 'like',
                            component : like,
                            meta : {
                                notAudio : false,
                                notNavBar : false,
                            }
                        },
                        {
                            path : '/setting',
                            name : 'setting',
                            component : setting,
                            meta : {
                                title : '设置'
                            }
                        },
                        {
                            path : '/bookReadSetting',
                            name : 'bookReadSetting',
                            component : bookReadSetting,
                            meta : {
                                title : '书籍阅读设置'
                            }
                        },
                        {
                            path : '/search',
                            name : 'search',
                            component : search,
                            meta : {
                                notNavBar : true
                            }
                        },
                        {
                            path : '/collection',
                            name : 'collection',
                            component : collection
                        },
                        {
                            path : '/clockBoots',
                            name : 'clockBoots',
                            component : clockBoots,
                            meta : {
                                notAudio : true,
                                title : '浏览记录'
                            }
                        },
                        {
                            path : '/bookDetail',
                            name : 'bookDetail',
                            component : bookDetail,
                            meta : {
                                notAudio : true,
                                title : '书籍详情',
                            }
                        },
                        {
                            path : '/bookRead',
                            name : 'bookRead',
                            component : bookRead,
                            meta : {
                                notAudio : true,
                                notNavBar : true
                            }
                        },
                        {
                            path : '/songDetail',
                            name : 'songDetail',
                            component : songDetail,
                            meta : {
                                notAudio : true,
                                notNavBar : true,
                            }
                        },
                        // 小说分类
                        {
                            path : '/fictionClass',
                            name : 'fictionClass',
                            component : fictionClass,
                            meta : {
                                notAudio : true,
                                title : '分类',
                                NavBarRightTitle : '全部分类',
                                NavBarRightPath : '/fictionList',
                            }
                        },
                        // 小说列表
                        {
                            path : '/fictionList',
                            name : 'fictionList',
                            component : fictionList,
                            meta : {
                                notAudio : true,
                                title : '全部分类',
                                NavBarRightIcon : 'search',
                                NavBarRightPath : '/search?type=0',
                            }
                        },
                        // 歌单列表
                        {
                            path : '/songSheet',
                            name : 'songSheet',
                            component : songSheet,
                            meta : {
                                notAudio : true,
                                title : '歌单列表',
                                NavBarRightTitle : '新建歌单',
                                NavBarRightPath : '/createSongSheet',
                            }
                        },
                        // 添加歌单列表
                        {
                            path : '/createSongSheet',
                            name : 'createSongSheet',
                            component : createSongSheet,
                            meta : {
                                notAudio : true,
                                title : '编辑歌单',
                            }
                        },
                        // 影视播放页面
                        {
                            path : '/moviesPlay',
                            name : 'moviesPlay',
                            component : moviesPlay,
                            meta : {
                                notAudio : true,
                                notNavBar : true
                            }
                        },
                        // 影视详情
                        {
                            path : '/moviesDetail',
                            name : 'moviesDetail',
                            component : moviesDetail,
                            meta : {
                                notAudio : true,
                                title : '影视详情'
                            }
                        },
                    ]
                },
            ]
        },
        {
            path : '/login',
            name : 'login',
            component : login
        },
        // MV视频
        {
            path : '/video',
            name : 'video',
            component : video
        },
        {
            path : '/downClient',
            name : 'downClient',
            component : downClient
        },
        {
            path : '/findPassword',
            name : 'findPassword',
            component : findPassword
        },
        {
            path : '/userUpdate',
            name : 'userUpdate',
            component : userUpdate
        }
    ],
})



// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push (location) {
//   return originalPush.call(this, location).catch(err => err)
// }



router.beforeEach((to, from, next) => {
    // console.log('to', to);
    // console.log('from', from);
    next()
})

export default router